import os
import zipfile

py_home = os.path.abspath(os.curdir)
keystore = py_home + os.sep + "shanpaosign.keystore"
if __name__ == '__main__':
    listdir = os.listdir("channel_files")
    count = 0
    for apk in listdir:
        apk_path = py_home + os.sep + "channel_files" + os.sep + apk
        path = "apksigner sign -verbose  " + keystore + " --ks-key-alias shanpao --ks-pass pass:android " + apk_path
        print(path)
        os.system(path)
        count = count + 1
        print("已完成" + str(count) + "个文件")
        print(apk_path)
        zip = zipfile.ZipFile(apk_path, 'a', zipfile.ZIP_DEFLATED)
        extract = zip.extract("/META-INF", "channel_files")
